package com.erp.module.ProjectOrderProcess

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.bean.ProjectOrderProcessBean
import com.erp.util.Myutil

class ProjectOrderProcessP : ProjectOrderProcessContract.ProjectOrderProcessKP {
    var context: Context
    var mlist : MutableList<String>
    var PV : ProjectOrderProcessContract.ProjectOrderProcessPutView?=null
    var MP : ProjectOrderProcessContract.ProjectOrderProcessMP = ProjectOrderProcessM()
    var code = 1

    constructor(mlist: MutableList<String> , PV: ProjectOrderProcessContract.ProjectOrderProcessPutView, context: Context,code : Int) {
        this.code = code
        this.mlist = mlist
        this.PV = PV
        this.context=context
    }

    override fun putProjectOrderProcess() {
        var ProjectOrderProcessBeanList : MutableList<ProjectOrderProcessBean> = ArrayList()
        for (i in 0 until mlist.size){
            var bean = ProjectOrderProcessBean()
            bean.scrn_string = mlist[i]
            when(code){
                1 -> {
                    bean.process = "开料"
                }
                2 -> {
                    bean.process = "封边"
                }
                3 -> {
                    bean.process = "打孔"
                }
                4 -> {
                    bean.process = "分包"
                }
            }
            ProjectOrderProcessBeanList.add(bean)
        }
        if(mlist.size == 0){
            Myutil.MyTost("没有扫描，不能上传")
        }
        MP.putProjectOrderProcess(context,ProjectOrderProcessBeanList,object : OnUserDataInterface{
            override fun onUserData(data: String?) {
                PV?.putProjectOrderProcessOk()
            }

            override fun onNot(throwable: String?) {
                PV?.putProjectOrderProcessNo()
            }

        })

    }
}